<template>
  <body id="poster">
    <el-form class="login-container" label-position="left" label-width="0px">

      <h3 class="login_title">
        系统登录
        <el-button @click="ToRegister()">点我注册</el-button>
      </h3>


      <el-form-item label="">
        <el-input type="text" v-model="loginForm.userName" placeholder="请输入您的账号" prefix-icon="el-icon-user-solid"
          autocomplete="off" clearable></el-input>
      </el-form-item>



      <el-form-item label="">
        <el-input type="password" v-model="loginForm.password" placeholder="请输入您的密码" prefix-icon="el-icon-s-goods"
          autocomplete="off" clearable></el-input>
      </el-form-item>



      <el-form-item>
        <el-button type="primary" @click="Login()"
          style="width: 100px;background-color: #505458;border: none;">立即登录</el-button>
      </el-form-item>

    </el-form>
  </body>
</template>
  
<script>


export default {
  name: 'Login',
  data() {
    return {
      loginForm: {
        userName: "",
        password: ""
      }
    }
  },
  methods: {
    //登录
    Login() {
      //发送给后端的请求
      console.log(this.loginForm)
      this.axios.post('http://localhost:9999/sys/login', this.loginForm).then(Response => {
        
        console.log("接收的数据"+Response.data);
        if (Response.data.code=="20000") {
          this.loginForm = {};
          this.$message({
            message: "登录成功！",
            type: 'success'
          })

          //跳转主页面
          this.$router.push({path:'/home'});
        }
      })
    },



    ToRegister() {
      this.$router.push({ path: '/Register' })
    }
  }
}
</script>


<style>
#poster {
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;

}

body {
  margin: 0px;
  padding: 0px;
  ;
}

.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 30px;
  /* 设置统一的内边距值 */
  background-color: #5791c0;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}


.login_title {
  margin: 0 auto 40px auto;
  text-align: center;
  color: #505458;
}
</style>